<?php

require_once('functions/connect_to_database.php');
include_once("functions/session.php");



?>

<!DOCTYPE html>

<html lang="en">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>TOTEG&reg;</title>
		<?php
			//include all of the scripts and style sheets 
			include("ajax/includes.php"); 
		?> 
	</head>

	<script type="text/javascript">
	
		var user = <?php echo( "'".(isset($_SESSION['usr']) ? $_SESSION['usr'] : "")."'" ) ?>;
	
		/*
		* Calls getProjects which posts to functions/get_projects.php
		* to get the current logged-in user's projects and display them in a drop
		* down box in the panel. 
		*/
		getProjects();
		function getProjects(){
			//get the user's name from php session
		
			$.post('functions/get_projects.php', {"user": user}, function(data) {
				$("#user_projects").html(data);
			});
		}
		
		
		/*
		* Adds a project to the database by posting to functions/add_project.php.
		* This is called when the user hits the "submit" button in the panel when
		* creating a new project.
		*	The add_projects.php page returns the updated project names in html form,
		* ready to be used in the post's callback.
		*/
		function addProject(){
			//get the user's name from php session
			var project = $("#name").val();

			$.post('functions/add_project.php', {"user": user, "name":project}, function(data){
				$("#user_projects").html(data);
			});
			//clear the name field
			$("#name").val("");
		}
	</script>
	
	<!--<script type="text/javascript">
			// Check if the user has been active, i.e. mouse movement, mouse click, keystrocks, mouse wheel action.   
		    (function($){
		      
		        var timeout = 10000;
		        var username = ?php echo( "'".$_SESSION['usr']."'" ) ?>;

		        $(document).bind("idle.idleTimer", function(){
		        	$.post("functions/logout.php", {"username":username}, function(){
		    			window.location = "index.php";
		    			//alert("Looged Off");
		    		});
		        });
		        
		        $.idleTimer(timeout);
		    
		    
		   })(jQuery);
	</script>


	--><body>
		<script>
			$("body").addClass("imageBg");
		</script>

		<?php include("ajax/panel.php"); ?>

		<div id="pageContent"></div>

	</body>
</html>
